home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 26
/
Cream of the Crop 26.iso
/
program
/
ddj0897.zip
/
DYN401.ZIP
/
class
/
shortint.c
< prev
next >
Wrap
C/C++ Source or Header
|
1997-04-16
|
5KB
|
194 lines
/* Copyright (c) 1993-1996 Algorithms Corporation */
/* All rights reserved. */
/* This file automatically generated by dpp - do not edit */
#define DPP_STRATEGY 2
#define DPP_FASTWIDE 0
#line 15 "shortint.d"
#include <math.h>
#define CLASS ShortInteger_c
#define ivType ShortInteger_iv_t
#include "generics.h"
object ShortInteger_c;
#line 28 "shortint.c"
typedef struct _ShortInteger_iv_t {
short int iVal;
} ShortInteger_iv_t;
#line 21 "shortint.d"
cmeth objrtn ShortInteger_cm_gNewWithInt(object self, int val)
{
object obj = oSuper(ShortInteger_c, gNew, self)(self);
ivType *iv = ivPtr(obj);
iv->iVal = (short int) val;
return(obj);
}
imeth int ShortInteger_im_gHash(object self)
{ ShortInteger_iv_t *iv = GetIVs(ShortInteger, self);
double t;
t = .6125423371 * (unsigned) iv->iVal;
t = t < 0.0 ? -t : t;
return (int) (BIG_INT * (t - floor(t)));
}
imeth int ShortInteger_im_gCompare(object self, object obj)
{ ShortInteger_iv_t *iv = GetIVs(ShortInteger, self);
short sv, ov;
ChkArg(obj, 2);
if (ClassOf(obj) != CLASS)
return oSuper(ShortInteger_c, gCompare, self)(self, obj);
if ((sv=iv->iVal) < (ov=ivPtr(obj)->iVal))
return -1;
else if (sv == ov)
return 0;
else
return 1;
}
imeth objrtn ShortInteger_im_gStringRepValue(object self)
{ ShortInteger_iv_t *iv = GetIVs(ShortInteger, self);
return vSprintf(String, "%hd", iv->iVal);
}
imeth char ShortInteger_im_gCharValue(object self)
{ ShortInteger_iv_t *iv = GetIVs(ShortInteger, self);
return (char) iv->iVal;
}
imeth short ShortInteger_im_gShortValue(object self)
{ ShortInteger_iv_t *iv = GetIVs(ShortInteger, self);
return (short) iv->iVal;
}
imeth unsigned short ShortInteger_im_gUnsignedShortValue(object self)
{ ShortInteger_iv_t *iv = GetIVs(ShortInteger, self);
return (unsigned short) iv->iVal;
}
imeth long ShortInteger_im_gLongValue(object self)
{ ShortInteger_iv_t *iv = GetIVs(ShortInteger, self);
return (long) iv->iVal;
}
imeth double ShortInteger_im_gDoubleValue(object self)
{ ShortInteger_iv_t *iv = GetIVs(ShortInteger, self);
return (double) iv->iVal;
}
imeth void * ShortInteger_im_gPointerValue(object self)
{ ShortInteger_iv_t *iv = GetIVs(ShortInteger, self);
return (void *) &iv->iVal;
}
imeth objrtn ShortInteger_im_gChangeValue(object self, object val)
{ ShortInteger_iv_t *iv = GetIVs(ShortInteger, self);
ChkArg(val, 2);
iv->iVal = gShortValue(val);
return self;
}
imeth objrtn ShortInteger_im_gChangeCharValue(object self, int val)
{ ShortInteger_iv_t *iv = GetIVs(ShortInteger, self);
iv->iVal = (short) val;
return self;
}
imeth objrtn ShortInteger_im_gChangeShortValue(object self, int val)
{ ShortInteger_iv_t *iv = GetIVs(ShortInteger, self);
iv->iVal = (short) val;
return self;
}
imeth objrtn ShortInteger_im_gChangeUShortValue(object self, unsigned val)
{ ShortInteger_iv_t *iv = GetIVs(ShortInteger, self);
iv->iVal = (short) val;
return self;
}
imeth objrtn ShortInteger_im_gChangeLongValue(object self, long val)
{ ShortInteger_iv_t *iv = GetIVs(ShortInteger, self);
iv->iVal = (short) val;
return self;
}
imeth objrtn ShortInteger_im_gChangeDoubleValue(object self, double val)
{ ShortInteger_iv_t *iv = GetIVs(ShortInteger, self);
iv->iVal = (short) val;
return self;
}
#line 141 "shortint.c"
objrtn ShortInteger_initialize(void)
{
static CRITICALSECTION cs;
static int volatile once = 0;
ENTERCRITICALSECTION(_CI_CS_);
if (!once) {
INITIALIZECRITICALSECTION(cs);
once = 1;
}
LEAVECRITICALSECTION(_CI_CS_);
ENTERCRITICALSECTION(cs);
if (ShortInteger_c) {
LEAVECRITICALSECTION(cs);
return ShortInteger_c;
}
INHIBIT_THREADER;
Number_initialize();
if (ShortInteger_c) {
ENABLE_THREADER;
LEAVECRITICALSECTION(cs);
return ShortInteger_c;
}
ShortInteger_c = gNewClass(Class, "ShortInteger", sizeof(ShortInteger_iv_t), 0, Number, END);
cMethodFor(ShortInteger, gNewWithInt, ShortInteger_cm_gNewWithInt);
iMethodFor(ShortInteger, gUnsignedShortValue, ShortInteger_im_gUnsignedShortValue);
iMethodFor(ShortInteger, gChangeDoubleValue, ShortInteger_im_gChangeDoubleValue);
iMethodFor(ShortInteger, gDoubleValue, ShortInteger_im_gDoubleValue);
iMethodFor(ShortInteger, gCompare, ShortInteger_im_gCompare);
iMethodFor(ShortInteger, gChangeLongValue, ShortInteger_im_gChangeLongValue);
iMethodFor(ShortInteger, gChangeShortValue, ShortInteger_im_gChangeShortValue);
iMethodFor(ShortInteger, gShortValue, ShortInteger_im_gShortValue);
iMethodFor(ShortInteger, gPointerValue, ShortInteger_im_gPointerValue);
iMethodFor(ShortInteger, gCharValue, ShortInteger_im_gCharValue);
iMethodFor(ShortInteger, gStringRepValue, ShortInteger_im_gStringRepValue);
iMethodFor(ShortInteger, gChangeUShortValue, ShortInteger_im_gChangeUShortValue);
iMethodFor(ShortInteger, gHash, ShortInteger_im_gHash);
iMethodFor(ShortInteger, gChangeValue, ShortInteger_im_gChangeValue);
iMethodFor(ShortInteger, gLongValue, ShortInteger_im_gLongValue);
iMethodFor(ShortInteger, gChangeCharValue, ShortInteger_im_gChangeCharValue);
ENABLE_THREADER;
LEAVECRITICALSECTION(cs);
return ShortInteger_c;
}